package xyz.xmh.pattern.behavioral.strategypattern;

/**
 * @author Administrator
 * <p>
 * 策略模式演示类
 */
public class StrategyPatternDemo {

    public static void main(String[] args) {
        // 创建要进行的策略对象
        Context context = new Context();

        context.setStrategy(new OperationAdd());
        System.out.println("10 + 5 = " + context.executeStrategy(10, 5));

        context.setStrategy(new OperationSubtract());
        System.out.println("10 - 5 = " + context.executeStrategy(10, 5));

        context.setStrategy(new OperationMultiply());
        System.out.println("10 * 5 = " + context.executeStrategy(10, 5));
    }
}
